import {httpRequest} from '@/utils/http';
import {UpkeepInfoVO, UpkeepInfoForm, UpkeepInfoQuery} from '@/api/iot/upkeepInfo/types';

enum Api {
    root = '/iot/upkeepInfo',
    list = '/iot/upkeepInfo/list',
    startUpkeep = '/iot/upkeepInfo/startUpkeep/',
    detail = '/iot/upkeepInfo/projectDetail',
    submitUpkeepAuditInfo = '/iot/upkeepInfo/submitUpkeepAuditInfo',
}

/**
 * 查询电梯保养信息列表
 * @param query
 * @returns {*}
 */
export function listUpkeepInfo(query?: UpkeepInfoQuery) {
    return httpRequest.get<UpkeepInfoVO[]>({url: Api.list, data: query});
}

/**
 * 查询电梯保养信息详细
 * @param upkeepId
 */
export function getUpkeepInfo(upkeepId: string | number) {
    return httpRequest.get<UpkeepInfoVO>({url: Api.root + '/' + upkeepId});
}

/**
 * 新增电梯保养信息
 * @param data
 */
export function addUpkeepInfo(data: UpkeepInfoForm) {
    return httpRequest.post({url: Api.root, data});
}

/**
 * 修改电梯保养信息
 * @param data
 */
export function updateUpkeepInfo(data: UpkeepInfoForm) {
    return httpRequest.put({url: Api.root, data});
}

/**
 * 删除电梯保养信息
 * @param upkeepId
 */
export function deleteUpkeepInfo(upkeepId: string | number) {
    return httpRequest.delete({url: Api.root + '/' + upkeepId});
}

/**
 * 开始保养
 * @param upkeepId
 */
export function startUpkeep(upkeepId: string | number) {
    return httpRequest.get({url: Api.startUpkeep + upkeepId});
}

/**
 * 进行保养项目清单页面详情接口
 */
export function getUpkeepDetail(upkeepId: string | number, projectType: string) {
    let data: any = {};
    if (upkeepId) {
        data["upkeepId"] = upkeepId;
    }
    if (projectType) {
        data["projectType"] = projectType;
    }
    return httpRequest.get({url: Api.detail, data: data});
}

/**
 * 提交保养审核信息
 * @param data
 */
export function submitUpkeepAuditInfo(data: any) {
    return httpRequest.post({url: Api.submitUpkeepAuditInfo, data});
}
